const path = require("path");
const { name } = require("./package");

function resolve (dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  publicPath: "./",
  //输出文件目录
  outputDir: "dist",
  //webpack-dev-server相关配置
  devServer: {
    port: 8088,
    open: true,

    proxy: {
      "/api": {
        target: 'http://pts.dct99.com:66/partyBuildCockpitPre', //线上
        // target: 'http://pts.dct99.com:66/partyBuildCockpit', //测试
        // target: "http://zhdj.hcyjw.cn/api",
        ws: true, //如果要代理 websockets，配置这个参数
        secure: false, // 如果是https接口，需要配置这个参数
        changeOrigin: true, //是否跨域
        pathRewrite: {
          "^/api": "",
        },
      },
    },

    headers: {
      "Access-Control-Allow-Origin": "*",
    },
  },
  configureWebpack: {
    name: "党建信息化管理系统",
    resolve: {
      alias: {
        "@": resolve("src"),
      },
    },
    plugins: [],
    output: {
      library: `${name}-[name]`,
      libraryTarget: "umd", // 把微应用打包成 umd 库格式
      jsonpFunction: `webpackJsonp_${name}`,
    },
    externals: {
      vue: "Vue",
      vuex: "Vuex",
      "vue-router": "VueRouter",
      "element-ui": "ELEMENT",
    },
  },
  chainWebpack: (config) => {
    config.module
      .rule("fonts")
      .test(/.(ttf|otf|eot|woff|woff2)$/)
      .use("url-loader")
      .loader("url-loader")
      .options({})
      .end();
  },
};
